home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 72 / IOPROG_72.ISO / soft / c++ / NCTDiscWriter2.exe / {app} / MS C# 7.0 Samples / TestCSDataCDWriter / frmErase.cs < prev    next >
Encoding:
Text File  |  2003-03-04  |  5.1 KB  |  184 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6.  
  7. namespace DiskWriter
  8. {
  9.     /// <summary>
  10.     /// Summary description for frmErase.
  11.     /// </summary>
  12.     public class frmErase : System.Windows.Forms.Form
  13.     {
  14.         internal System.Windows.Forms.RadioButton eraseQuickOpt;
  15.         internal System.Windows.Forms.RadioButton eraseFullOpt;
  16.         internal System.Windows.Forms.Button EraseBtn;
  17.         internal System.Windows.Forms.ProgressBar ProgressBar1;
  18.         bool quickErase;
  19.         bool EraseInProgress;
  20.         public Form1 frm;
  21.         /// <summary>
  22.         /// Required designer variable.
  23.         /// </summary>
  24.         private System.ComponentModel.Container components = null;
  25.  
  26.         public frmErase()
  27.         {
  28.             //
  29.             // Required for Windows Form Designer support
  30.             //
  31.             InitializeComponent();
  32.             quickErase = true;
  33.             EraseInProgress = false;
  34.  
  35.             //
  36.             // TODO: Add any constructor code after InitializeComponent call
  37.             //
  38.         }
  39.  
  40.         /// <summary>
  41.         /// Clean up any resources being used.
  42.         /// </summary>
  43.         protected override void Dispose( bool disposing )
  44.         {
  45.             if( disposing )
  46.             {
  47.                 if(components != null)
  48.                 {
  49.                     components.Dispose();
  50.                 }
  51.             }
  52.             base.Dispose( disposing );
  53.         }
  54.  
  55.         #region Windows Form Designer generated code
  56.         /// <summary>
  57.         /// Required method for Designer support - do not modify
  58.         /// the contents of this method with the code editor.
  59.         /// </summary>
  60.         private void InitializeComponent()
  61.         {
  62.             this.eraseQuickOpt = new System.Windows.Forms.RadioButton();
  63.             this.eraseFullOpt = new System.Windows.Forms.RadioButton();
  64.             this.EraseBtn = new System.Windows.Forms.Button();
  65.             this.ProgressBar1 = new System.Windows.Forms.ProgressBar();
  66.             this.SuspendLayout();
  67.             // 
  68.             // eraseQuickOpt
  69.             // 
  70.             this.eraseQuickOpt.Checked = true;
  71.             this.eraseQuickOpt.Location = new System.Drawing.Point(8, 8);
  72.             this.eraseQuickOpt.Name = "eraseQuickOpt";
  73.             this.eraseQuickOpt.Size = new System.Drawing.Size(149, 19);
  74.             this.eraseQuickOpt.TabIndex = 1;
  75.             this.eraseQuickOpt.TabStop = true;
  76.             this.eraseQuickOpt.Text = "Quick Erase (TOC Only)";
  77.             this.eraseQuickOpt.CheckedChanged += new System.EventHandler(this.eraseQuickOpt_CheckedChanged);
  78.             // 
  79.             // eraseFullOpt
  80.             // 
  81.             this.eraseFullOpt.Location = new System.Drawing.Point(8, 32);
  82.             this.eraseFullOpt.Name = "eraseFullOpt";
  83.             this.eraseFullOpt.Size = new System.Drawing.Size(150, 19);
  84.             this.eraseFullOpt.TabIndex = 2;
  85.             this.eraseFullOpt.Text = "Full Erase";
  86.             this.eraseFullOpt.CheckedChanged += new System.EventHandler(this.eraseFullOpt_CheckedChanged);
  87.             // 
  88.             // EraseBtn
  89.             // 
  90.             this.EraseBtn.Location = new System.Drawing.Point(160, 8);
  91.             this.EraseBtn.Name = "EraseBtn";
  92.             this.EraseBtn.Size = new System.Drawing.Size(91, 18);
  93.             this.EraseBtn.TabIndex = 3;
  94.             this.EraseBtn.Text = "Erase";
  95.             this.EraseBtn.Click += new System.EventHandler(this.EraseBtn_Click);
  96.             // 
  97.             // ProgressBar1
  98.             // 
  99.             this.ProgressBar1.Location = new System.Drawing.Point(0, 56);
  100.             this.ProgressBar1.Name = "ProgressBar1";
  101.             this.ProgressBar1.Size = new System.Drawing.Size(256, 12);
  102.             this.ProgressBar1.TabIndex = 5;
  103.             // 
  104.             // frmErase
  105.             // 
  106.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  107.             this.ClientSize = new System.Drawing.Size(256, 77);
  108.             this.Controls.AddRange(new System.Windows.Forms.Control[] {
  109.                                                                           this.ProgressBar1,
  110.                                                                           this.EraseBtn,
  111.                                                                           this.eraseFullOpt,
  112.                                                                           this.eraseQuickOpt});
  113.             this.MaximizeBox = false;
  114.             this.MinimizeBox = false;
  115.             this.Name = "frmErase";
  116.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  117.             this.Text = "frmErase";
  118.             this.Load += new System.EventHandler(this.frmErase_Load);
  119.             this.ResumeLayout(false);
  120.  
  121.         }
  122.         #endregion
  123.  
  124.         private void eraseQuickOpt_CheckedChanged(object sender, System.EventArgs e)
  125.         {
  126.             quickErase = true;
  127.         }
  128.  
  129.         private void eraseFullOpt_CheckedChanged(object sender, System.EventArgs e)
  130.         {
  131.             quickErase = false;
  132.         }
  133.  
  134.         private void EraseBtn_Click(object sender, System.EventArgs e)
  135.         {
  136.             EraseBtn.Enabled = false;
  137.  
  138.             frm.err = false;
  139.             EraseInProgress = true;
  140.             this.Refresh();
  141.             frm.DataCDWriter1.Erase(true);
  142.             if( frm.err == true )
  143.             {
  144.                 StopErase();
  145.                 frm.err = false;
  146.                 this.Hide();
  147.             }
  148.  
  149.             while( frm.eraseProgress < 100 )
  150.             {
  151.                 Application.DoEvents();
  152.                 if( frm.OperationProgress == true )
  153.                 {
  154.                     ProgressBar1.Value = frm.eraseProgress;
  155.                 }
  156.                 frm.OperationProgress = false;
  157.                 Application.DoEvents();
  158.             }
  159.             frm.eraseProgress = 100;
  160.             ProgressBar1.Value = frm.eraseProgress;
  161.             MessageBox.Show("Erase Complete!");
  162.             StopErase();
  163.         }
  164.  
  165.         private void frmErase_Load(object sender, System.EventArgs e)
  166.         {
  167.             frm = (Form1)this.Owner;
  168.             quickErase = true;
  169.             EraseInProgress = false;
  170.         }
  171.  
  172.         private void StopErase()
  173.         {
  174.             EraseInProgress = false;
  175.             EraseBtn.Enabled = true;
  176.             ProgressBar1.Value = 0;
  177.             frm.RefreshDiskInfo();
  178.             frm.err = false;
  179.             this.Hide();
  180.         }
  181.  
  182.     }
  183. }
  184.